
#ifndef __IIC_H_
#define __IIC_H_

#include "bsp.h"


#define IIC_SDA_HIGH() GPIO_SetBits(GPIOB, GPIO_Pin_14)
#define IIC_SDA_LOW()  GPIO_ResetBits(GPIOB, GPIO_Pin_14)
#define IIC_SCL_HIGH() GPIO_SetBits(GPIOB, GPIO_Pin_13)
#define IIC_SCL_LOW()  GPIO_ResetBits(GPIOB, GPIO_Pin_13)
#define IIC_READ_SDA() GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_14)


void IIC_Init(void);
void IIC_SDA_Out(void);
void IIC_SDA_In(void);

void IIC_Start(void);
void IIC_Stop(void);
uint8_t IIC_Wait_Ack(void);
void IIC_Ack(void);

void IIC_NAck(void);
void IIC_Send_Byte(uint8_t txd);
uint8_t IIC_Read_Byte(uint8_t ack);


uint8_t CYMBR3_ReadOneByte(uint16_t slave_addr,uint16_t ReadAddr);
void CYMBR3_WriteOneByte(uint16_t WriteAddr,uint16_t regaddr,uint8_t DataToWrite);

void CYMBR3_Write_NByte(uint16_t WriteAddr,uint16_t RegAddr,uint8_t *pbuff,uint16_t buff_len);
void CYMBR3_Read_NByte(uint16_t ReadAddr,uint16_t RegAddr,uint8_t *pbuff,uint16_t buff_len);


#endif
